import React, { useState, useEffect } from 'react'
import store from './redux/store'
export default function (WrappedComponent) {
  return function Far() {
    const [x, setX] = useState(0)
    useEffect(() => {
      store.subscribe(() => {
        //   console.log(store.getState())
        // 只要这个函数执行,意味着redux数据变化, 就需要让Count组件更新
        setX((x) => {
          return x + 1
        })
      })
    }, [])
    return (
      <WrappedComponent
        state={store.getState()}
        dispatch={store.dispatch}
      ></WrappedComponent>
    )
  }
}
